package net.pinnoocle.playdao.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.pinnoocle.playdao.entity.Shop;
import net.pinnoocle.playdao.entity.ShopFinance;
import net.pinnoocle.playdao.entity.SimpleUserInfoVo;
import net.pinnoocle.playdao.entity.admin.RegisterWechatSearchParams;
import net.pinnoocle.playdao.entity.admin.ShopListSearchVo;
import net.pinnoocle.playdao.entity.admin.ShopListVo;
import net.pinnoocle.playdao.entity.admin.homepage.TopShopByGroup;
import net.pinnoocle.playdao.entity.shopPc.finance.ShopFinanceListPageVo;
import net.pinnoocle.playdao.entity.shopPc.finance.ShopFinanceListSearchParams;
import net.pinnoocle.playdao.entity.shopPc.user.UserListPageVo;
import net.pinnoocle.playdao.entity.web.shop.ExpenseDetailListPageVo;
import net.pinnoocle.playdao.entity.web.shop.ExpenseDetailSearchParams;
import net.pinnoocle.playdao.entity.web.shop.UserListSearchParams;
import net.pinnoocle.playdao.entity.wechat.RegisterWechatListParams;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 门店表(Shop)表数据库访问层
 *
 * @author ye
 * @since 2021-10-19 10:24:27
 */
@Mapper
public interface ShopDao extends BaseMapper<Shop> {

    /**
     * 店铺列表
     * @param page
     * @param params
     * @return
     */
    Page<ShopListVo> shopList(Page page, @Param("params") ShopListSearchVo params);

    /**
     * 今日统计
     * @param shopId
     * @param startTime
     * @param endTime
     * @return
     */
    HashMap<String,Object> shopStatistics(@Param("shopId") String shopId,
                      @Param("startTime") String startTime,
                      @Param("endTime") String endTime);


    /**
     * 当前开局数
     * @param shopId
     * @return
     */
    int nowGroupNum(@Param("shopId") String shopId);

    /**
     * 会员列表
     * @param page
     * @param searchParams
     * @return
     */
    Page<UserListPageVo> userList(Page page, @Param("params") UserListSearchParams searchParams);

    /**
     * 用户消费明细
     * @param page
     * @param searchParams
     * @return
     */
    Page<ExpenseDetailListPageVo> expenseDetailPage(Page page, @Param("params") ExpenseDetailSearchParams searchParams);

    /**
     * 消费总金额
     * @param userId
     * @return
     */
    double totalExpenseAmount(@Param("userId") String userId);

    /**
     * 组局玩家列表
     * @param groupId
     * @return
     */
    List<SimpleUserInfoVo> userInGroup(@Param("groupId") String groupId);

    /**
     * 店铺资产概况
     * @param page
     * @param params
     * @return
     */
    Page<ShopFinanceListPageVo> shopFinanceList(Page page, @Param("params")ShopFinanceListSearchParams params);

    /**
     * 门店总收入/总支出
     * @param shopId
     * @param financeType
     * @return
     */
    BigDecimal totalIncomeExpendAmount(@Param("shopId") String shopId,
                                       @Param("financeType") Integer financeType,
                                       @Param("startTime") String startTime,
                                       @Param("endTime") String endTime);


    /**
     * 小程序申请注册列表
     * @param page
     * @param searchParams
     * @return
     */
    Page<RegisterWechatListParams> registerWechat(Page page, @Param("params") RegisterWechatSearchParams searchParams);

    /**
     * 根据组局数店铺排行
     * @param offset
     * @return
     */
    List<TopShopByGroup> topShopByGroup(@Param("offset") Integer offset);
}